package com.yuw.inner.jubu;

public class Student {

	// 属性
	// 成员变量
	private String stuName;
	private String stuSex;
	private double stuScore;

	private Object obj;

	// 行为
	/**
	 * 学习行为
	 */
	public void doStuding() {
		System.out.println(this.stuName + " is studing...");
	}

	/**
	 * 使用内部类输出学生的家庭成员信息
	 */
	public void printMeInfo() {

		// 局部变量
		/*
		 * 如果该局部变量被局部内部类使用，则在jdk1.8之前需要使用final修饰，1.8+之后不需要使用final修饰；
		 * 虽然jdk1.8之后没有写final，但是被局部内部类访问的局部变量本质还是一个final方法，只不过是jvm默认提供的；
		 */
		int stuAge = 20;

		// 局部内部类:如果是private 只能本类使用
		class StuFamily {
			// 属性
			private String stuMatherName;
			private String stuFatherName;
			private String stuFamilyAddress;

			// 行为
			/**
			 * 获取学生家庭信息行为
			 * 
			 * @return
			 */
			public String getStuFamilyInfo() {
				// 局部内部类可以直接访问外部类的成员变量和成员方法
				/*
				 * 在局部内部类中使用外部局部变量 stuAge的值
				 * 如果该局部变量被局部内部类使用，则在jdk1.8之前需要使用final修饰，1.8+之后不需要使用final修饰；
				 */
				String str = "年龄为：" + stuAge + "的学生：" + getStuName() + "的家庭信息为：" + this.toString();
				return str;
			}

			public StuFamily(String stuMatherName, String stuFatherName, String stuFamilyAddress) {
				super();
				this.stuMatherName = stuMatherName;
				this.stuFatherName = stuFatherName;
				this.stuFamilyAddress = stuFamilyAddress;
			}

			public String getStuMatherName() {
				return stuMatherName;
			}

			public void setStuMatherName(String stuMatherName) {
				this.stuMatherName = stuMatherName;
			}

			public String getStuFatherName() {
				return stuFatherName;
			}

			public void setStuFatherName(String stuFatherName) {
				this.stuFatherName = stuFatherName;
			}

			public String getStuFamilyAddress() {
				return stuFamilyAddress;
			}

			public void setStuFamilyAddress(String stuFamilyAddress) {
				this.stuFamilyAddress = stuFamilyAddress;
			}

			@Override
			public String toString() {
				return "StuFamily [stuMatherName=" + stuMatherName + ", stuFatherName=" + stuFatherName
						+ ", stuFamilyAddress=" + stuFamilyAddress + "]";
			}

		}
		// 创建一个局部内部类的实例对象
		StuFamily stuF = new StuFamily("张三妈妈", "张三爸爸", "天津西青");
		System.out.println(stuF.getStuFamilyInfo());

		// stuAge = 30;

		// obj = stuF;
	}

	public Student(String stuName, String stuSex, double stuScore) {
		super();
		this.stuName = stuName;
		this.stuSex = stuSex;
		this.stuScore = stuScore;

	}

	public Student() {
		super();
		// TODO Auto-generated constructor stub
	}

	public String getStuName() {
		return stuName;
	}

	public void setStuName(String stuName) {
		this.stuName = stuName;
	}

	public String getStuSex() {
		return stuSex;
	}

	public void setStuSex(String stuSex) {
		this.stuSex = stuSex;
	}

	public double getStuScore() {
		return stuScore;
	}

	public void setStuScore(double stuScore) {
		this.stuScore = stuScore;
	}

}
